<?php

/**
 *  Ini adalah project open source yang dikembangkan oleh Impossible Team
 *
 *  Copyright (c) 2011 ekoindri. <ekoindri@ekoindri.com>
 *
 *  Versi: 1.2
 *  Developed by: Impossible Team
 *  Leader: Eko Indriyawan
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 *  USA
 *
 */

require_once("rpcl/rpcl.inc.php");
  //Includes
use_unit("webservices.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

function SIS_Login(
$server_host,
$server_database,
$server_username,
$server_password,
$user_name,
$user_password){
  $cek = mysql_connect($server_host, $server_username, $server_password);
  if($cek) {
    $cek2 = mysql_select_db($server_database) or die(mysql_error());
    if($cek) {
      mysql_close();
      mysql_connect($server_host, $server_username, $server_password);
      mysql_select_db($server_database) or die(mysql_error());

      $query = "
      SELECT  ID,
              USER_NAME,
              USER_PASSWORD,
              USER_NAMA_AWAL,
              USER_NAMA_TENGAH,
              USER_NAMA_AKHIR,
              USER_OTORISASI,
              USER_EMAIL,
              USER_WEBSITE,
              USER_YM,
              USER_ALAMAT,
              USER_KOTA,
              USER_PROPINSI,
              USER_KETERANGAN
      FROM    TABEL_USER
      WHERE   USER_NAME = '" . $user_name . "'
              ";
      $result = mysql_query($query);

      $numrows = mysql_num_rows($result);
      $Infologin = array();
      for($x = 0; $x < $numrows; $x++){
        $Infologin[] = mysql_fetch_array($result);
        }

      mysql_close();

      return $Infologin;
      }
    else {
      //return "Database tidak diketemukan";
      }
    } else {
    //return "Login gagal dilakukan";
    }
  }

function SIS_Daftar_NotArray(
$server_host,
$server_database,
$server_username,
$server_password,
$username,
$password,
$nama_awal,
$nama_tengah,
$nama_akhir,
$otorisasi,
$email,
$website,
$YM,
$alamat,
$kota,
$propinsi,
$keterngan){
  $cek = mysql_connect($server_host, $server_username, $server_password);
  if($cek) {
    $cek2 = mysql_select_db($server_database) or die(mysql_error());
    if($cek) {

      $query = "
      INSERT INTO   `TABEL_USER`
                (
                `USER_NAME`,
                `USER_PASSWORD`,
                `USER_NAMA_AWAL`,
                `USER_NAMA_TENGAH`,
                `USER_NAMA_AKHIR`,
                `USER_OTORISASI`,
                `USER_EMAIL`,
                `USER_WEBSITE`,
                `USER_YM`,
                `USER_ALAMAT`,
                `USER_KOTA`,
                `USER_PROPINSI`,
                `USER_KETERANGAN`
                )
      VALUES
                (
                '" . $username . "',
                '" . $password . "',
                '" . $nama_awal . "',
                '" . $nama_tengah . "',
                '" . $nama_akhir . "',
                '" . $otorisasi . "',
                '" . $email . "',
                '" . $website . "',
                '" . $YM . "',
                '" . $alamat . "',
                '" . $kota . "',
                '" . $propinsi . "',
                '" . $keterngan . "'
                )
                ";
      $result = mysql_query($query) or die(mysql_error());
      mysql_close();
      }
    }
  }

function SIS_Daftar_Array(
$server,
$input){

  $cek = mysql_connect($server[server_host], $server[server_username], $server[server_password]);
  if($cek) {
    $cek2 = mysql_select_db($server[server_database]) or die(mysql_error());
    if($cek) {

      $query = "
      INSERT INTO   `TABEL_USER`
                (
                `USER_NAME`,
                `USER_PASSWORD`,
                `USER_NAMA_AWAL`,
                `USER_NAMA_TENGAH`,
                `USER_NAMA_AKHIR`,
                `USER_OTORISASI`,
                `USER_EMAIL`,
                `USER_WEBSITE`,
                `USER_YM`,
                `USER_ALAMAT`,
                `USER_KOTA`,
                `USER_PROPINSI`,
                `USER_KETERANGAN`
                )
      VALUES
                (
                '" . $input[USER_NAME] . "',
                '" . $input[USER_PASSWORD] . "',
                '" . $input[USER_NAMA_AWAL] . "',
                '" . $input[USER_NAMA_TENGAH] . "',
                '" . $input[USER_NAMA_AKHIR] . "',
                '" . $input[USER_OTORISASI] . "',
                '" . $input[USER_EMAIL] . "',
                '" . $input[USER_WEBSITE] . "',
                '" . $input[USER_YM] . "',
                '" . $input[USER_ALAMAT] . "',
                '" . $input[USER_KOTA] . "',
                '" . $input[USER_PROPINSI] . "',
                '" . $input[USER_KETERANGAN] . "'
                )
                ";
      $result = mysql_query($query) or die(mysql_error());
      }
    }
  }

function TestInfologin($input){
  return $input[USER_NAME] .
  $input[USER_PASSWORD];
  }

  //Class definition
class DM_REGISTER extends DataModule{

  public $SIS_REGISTER = null;

  function SIS_REGISTERAddComplexTypes($sender, $params){

    $this->SIS_REGISTER->addComplexType(
    "TInfoServer",
    "complexType",
    "struct",
    "all",
    "",
    array(
          "server_host"=>array("name"=>"server_host", "type"=>"xsd:string"),
                               "server_database"=>array("name"=>"server_database", "type"=>"xsd:string"),
                                                        "server_username"=>array("name"=>"server_username", "type"=>"xsd:string"),
                                                                                 "server_password"=>array("name"=>"server_password", "type"=>"xsd:string")
                                                                                                          )
    );

    $this->SIS_REGISTER->addComplexType(
    "TInfologin",
    "complexType",
    "struct",
    "all",
    "",
    array(
          "ID"=>array("name"=>"ID", "type"=>"xsd:integer"),
                      "USER_NAME"=>array("name"=>"USER_NAME", "type"=>"xsd:string"),
                                         "USER_PASSWORD"=>array("name"=>"USER_PASSWORD", "type"=>"xsd:string"),
                                                                "USER_NAMA_AWAL"=>array("name"=>"USER_NAMA_AWAL", "type"=>"xsd:string"),
                                                                                        "USER_NAMA_TENGAH"=>array("name"=>"USER_NAMA_TENGAH", "type"=>"xsd:string"),
                                                                                                                  "USER_NAMA_AKHIR"=>array("name"=>"USER_NAMA_AKHIR", "type"=>"xsd:string"),
                                                                                                                                           "USER_OTORISASI"=>array("name"=>"USER_OTORISASI", "type"=>"xsd:string"),
                                                                                                                                                                   "USER_EMAIL"=>array("name"=>"USER_EMAIL", "type"=>"xsd:string"),
                                                                                                                                                                                       "USER_WEBSITE"=>array("name"=>"USER_WEBSITE", "type"=>"xsd:string"),
                                                                                                                                                                                                             "USER_YM"=>array("name"=>"USER_YM", "type"=>"xsd:string"),
                                                                                                                                                                                                                              "USER_ALAMAT"=>array("name"=>"USER_ALAMAT", "type"=>"xsd:string"),
                                                                                                                                                                                                                                                   "USER_KOTA"=>array("name"=>"USER_KOTA", "type"=>"xsd:string"),
                                                                                                                                                                                                                                                                      "USER_PROPINSI"=>array("name"=>"USER_PROPINSI", "type"=>"xsd:string"),
                                                                                                                                                                                                                                                                                             "USER_KETERANGAN"=>array("name"=>"USER_KETERANGAN", "type"=>"xsd:string")
                                                                                                                                                                                                                                                                                                                      )
    );

    $this->SIS_REGISTER->addComplexType(
    'TInfologins',
    'complexType',
    'array', '',
    'SOAP-ENC:Array', array(),
    array(array('ref'=>'SOAP-ENC:arrayType',
                'wsdl:arrayType'=>'tns:TInfologin[]')),
    'tns:TInfologin');

    }
  function SIS_REGISTERRegisterServices($sender, $params){
    $this->SIS_REGISTER->register(
    "SIS_Login",
    array(
          'server_host'=>'xsd:string',
          'server_database'=>'xsd:string',
          'server_username'=>'xsd:string',
          'server_password'=>'xsd:string',
          'user_name'=>'xsd:string',
          'user_password'=>'xsd:string'),
    array('return'=>'tns:TInfologins')
    );

    $this->SIS_REGISTER->register(
    "SIS_Daftar_NotArray",
    array(
          'server_host'=>'xsd:string',
          'server_database'=>'xsd:string',
          'server_username'=>'xsd:string',
          'server_password'=>'xsd:string',
          'username'=>'xsd:string',
          'password'=>'xsd:string',
          'nama_awal'=>'xsd:string',
          'nama_tengah'=>'xsd:string',
          'nama_akhir'=>'xsd:string',
          'otorisasi'=>'xsd:string',
          'email'=>'xsd:string',
          'website'=>'xsd:string',
          'YM'=>'xsd:string',
          'alamat'=>'xsd:string',
          'kota'=>'xsd:string',
          'propinsi'=>'xsd:string',
          'keterangan'=>'xsd:string'
          ),
    array('return'=>'xsd:string')
    );

    $this->SIS_REGISTER->register(
    "SIS_Daftar_Array",
    array(
          'server'=>'tns:TInfoServer',
          'input'=>'tns:TInfologin'
          ),
    array('return'=>'xsd:string')
    );

    $this->SIS_REGISTER->register(
    "TestInfologin",
    array(
          'input'=>'tns:TInfologin'
          ),
    array('return'=>'xsd:string')
    );

    }
  }

global $application;

global $DM_REGISTER;

  //Creates the form
$DM_REGISTER = new DM_REGISTER($application);

  //Read from resource file
$DM_REGISTER->loadResource(__FILE__);

?>